package com.example.service;

import com.example.entity.Contract;
import com.example.entity.Model;
import com.example.mapper.ModelMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
文物模型业务处理
 */
@Service
public class ModelService {

    @Resource
    private ModelMapper modelMapper;

    public void add(Model model) {
        modelMapper.insert(model);
    }

    public void deleteById(Integer id) {
        modelMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(Model model) {
        modelMapper.updateById(model);
    }

    public Model selectById(Integer id) {
        return modelMapper.selectById(id);
    }

    public List<Model> selectAll(Model model) {
        return modelMapper.selectAll(model);
    }

    public PageInfo<Model> selectPage(Model model, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Model> modelList = modelMapper.selectAll(model);
        return PageInfo.of(modelList);
    }
}
